//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "FrmNewSpoud.h"

//--> controllers
#include "IStudentDbSavingController.h"
#include "StudentDbSavingController.h"
#include "IStudentAddressSaver.h"
#include "StudentAddressSaver.h"
#include "DatabaseConnectionInformer.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFormNewSpoud *FormNewSpoud;

//--> create controllers
IStudentDbSavingController *StudentDbSaver ;
IStudentFatherSaver *StudentFatherSaver
IDatabaseConnectionInformer *iform;

//---------------------------------------------------------------------------
__fastcall TFormNewSpoud::TFormNewSpoud(TComponent* Owner)
        : TForm(Owner)
{
}
//save to controller ---------------------------------------------------------------------------
void __fastcall TFormNewSpoud::Button1Click(TObject *Sender)
{
iform=new IDatabaseConnectionInformer();
//orismos tis vasis pu prei na anoiksei
iform->setDbName("DataBase");   //prepei na deixnei sto onoma tis vasis dedomenwn
iform->setUsername("AdminUserDataBaseName"); //to onoma tou user Database
iform->setPassword("Password"); //kwdikos tou xristi

//apothikefsi dedomenwn stin vasi (meso controller -IDatabaseConnectionInformer- )
StudentDbSaver->saveStudent(Edit1->Text, Edit2->Text,iform);

//afm apo pou - den iparxei tetoio pedio?
//saveStudentFather(estw afm=1, *name, *lastName, *occupation,*aem,IDatabaseConnectionInformer *informer)
//molis twra dimiourgeite o foititis...apo pou pairnei to aem (arithmos mitroou) ?IDatabaseConnectionInformer?
//saveStudentFather(*afm, *name, *lastName, *occupation,*aem,IDatabaseConnectionInformer *informer)
StudentFatherSaver->saveStudentFather(10, Edit3->Text, Edit2->Text,null, 1,null,iform);


/*  stoixeia gia loader controllers gia neo foititi
onoma=Edit1->Text;
eponimo=Edit2->Text;
patronimo =Edit3->Text;
//apo to sistima// am =Edit4->Text;
//apo to sistima// am_math =Edit5->Text;
odeio=Edit6->Text;
odos_odeiou=Edit7->Text;
*/
this->Close();

}

//xrisimi gia tin emfanisi tou neou id tis gramateias
void My_update_form(TFormNewSpoud *mform){

/* kwdikas apo loader controllers pou anakta dedomena kai ta emfanizei stin forma */

  /*
mform->Edit4->Text=.am;
mform->Edit5->Text=.am_math;
    */
 }

//---------------------------------------------------------------------------
void __fastcall TFormNewSpoud::FormCreate(TObject *Sender)
{
 My_update_form(this);
}
//---------------------------------------------------------------------------
